﻿using CommandMgr.ServiceMgr;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using CommandMgr.Entities;

namespace CommandMgr.TestServiceMgr
{
    
    
    /// <summary>
    ///This is a test class for CommandServiceTest and is intended
    ///to contain all CommandServiceTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CommandServiceTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            CommandService service = new CommandService();
            service.DeleteCommand(CommandName);
        }
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private string CommandName = "Get My Foobar";
        private string CommandDescr = "This command will get my Foobar.";

        /// <summary>
        ///A test for AddCommand
        ///</summary>
        [TestMethod()]
        public void AddCommandTest()
        {
            CommandService target = new CommandService();
            target.AddCommand(CommandName, CommandDescr);
            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for AddCommand
        ///</summary>
        [TestMethod()]
        public void QueueCommandTest()
        {
            CommandService target = new CommandService();
            target.AddCommand(CommandName, CommandDescr);
            target.QueueCommand(CommandName);
            bool expectedResult = true;
            bool targetResult = target.DequeueCommand(CommandName);
            Assert.AreEqual(expectedResult, targetResult,"Error dequeing command");
            Command.CommandStatus expectedStatus = Command.CommandStatus.dequeued;
            Command.CommandStatus targetStatus = target.CheckStatus(CommandName);
            Assert.AreEqual(expectedStatus, targetStatus,"Status of command not updated correctly");

        }

    }
}
